package cn.itsource.basic.config;

import cn.itsource.user.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ItsourceWebMvcConfigurer implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

      /*
             /**: 拦截所有的请求，不管是多少级       /a  /a/b  /a/b/c...
            /*: 拦截所有的请求，但是只能拦截一级     /a /b /c  /a/b(拦截不了)
         */

        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/pay/notifyUrl")
                .excludePathPatterns("/pay/returnUrl")
                .excludePathPatterns("/shop/settlement")
                .excludePathPatterns("/fastdfs/**")
                .excludePathPatterns("/verification/**")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**")
                .excludePathPatterns("/wechat/**")
                .excludePathPatterns("/user/**");

    }
}
